package com.yisu.springboot.publisher;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @description: 使用StringRedisTemplate或RedisTemplate来发布消息到Redis的指定频道。
 * @author: xuyisu
 * @date: 2024-08-27
 */
@Component
public class RedisMessagePublisher {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void publish(String channel, String message) {
        stringRedisTemplate.convertAndSend(channel, message);
    }
}
